package com.azzaou.service.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.faces.model.SelectItem;

import com.azzaou.dao.IEmployeDao;
import com.azzaou.model.CategorieEmploye;
import com.azzaou.model.Chantier;
import com.azzaou.model.Employe;
import com.azzaou.model.EmployesAPayer;
import com.azzaou.model.Imputation;
import com.azzaou.model.PaiementEmploye;
import com.azzaou.service.IEmployeService;

public class EmployeService implements IEmployeService , Serializable {

	private static final long serialVersionUID = 1L;
	
	IEmployeDao employeDao;


	@Override
	public List<Employe> getEmployeByCriteria(Employe employe) {
		return employeDao.getEmployeByCriteria(employe);
	} 


	@Override
	public void saveOrUpdateEmploye(Employe employe) {
		employeDao.saveOrUpdateEmploye(employe);

	}
	/**
	 * Getter & Setter
	 * @return
	 */
	
	public IEmployeDao getEmployeDao() {
		return employeDao;
	}

	public void setEmployeDao(IEmployeDao employeDao) {
		this.employeDao = employeDao;
	}

	@Override
	public void removeEmploye(Employe employe) {
		this.employeDao.removeEmploye(employe);
		
	}


	@Override
	public List<String> employesByNames(String begin) {
		return employeDao.getEmployesByNames(begin);
	}


	@Override
	public List<Employe> getAllActifEmploye() {
		return employeDao.getAllActifEmploye();
	}


	@Override
	public List<CategorieEmploye> getAllCategorie() {
		return employeDao.getAllCategorie();
		
	}


	@Override
	public void saveOrUpdateCategorie(CategorieEmploye categorieEmploye) {
		employeDao.saveOrUpdateCategorie(categorieEmploye);
	}


	@Override
	public void removeCategorie(CategorieEmploye categorieEmploye) {
		employeDao.removeCategorie(categorieEmploye);
	}


	@Override
	public CategorieEmploye getCategorieEmployeById(Long id) {
		CategorieEmploye categorieEmploye = null;
		for (CategorieEmploye cat : getAllCategorie())
		{
			if(id.equals(cat.getId()))
			{
				categorieEmploye = cat;
				break;
			}
		}
		return categorieEmploye;
	}


	@Override
	public List<Employe> getAllEmployeByEchantier(Chantier chantierEnCours) {
		return employeDao.getAllEmployeByEchantier(chantierEnCours);
	}


	@Override
	public void saveImputations(List<Imputation> imputations) {
		employeDao.saveImputations(imputations);
		
	}


	@Override
	public List<Imputation> getImputations(Employe emp) {
		return employeDao.getImputations(emp);
	}


	@Override
	public List<Imputation> getImputationsEmployers(Chantier chantier) {
		return employeDao.getImputationsEmployers(chantier);
	}


	@Override
	public void saveOrUpdatePaiement(PaiementEmploye paiementEmploye) {
		employeDao.saveOrUpdatePaiement(paiementEmploye);
		
	}

	
	public List<CategorieEmploye> getCategEmployeByCriteria(CategorieEmploye categ)
	{
		return employeDao.getCategEmployeByCriteria(categ);
	}


	@Override
	public List<PaiementEmploye> getHistoriqueEmploye(Employe employe) {
		return employeDao.getHistoriqueEmploye(employe);
				
	}


	@Override
	public List<CategorieEmploye> getAllActifCategorie() {
		return employeDao.getAllActifCategorie();
	}


	@Override
	public List<Imputation> getImutationsPeriod(Chantier chantier,
			Date dateDebut, Date dateFin) {
		return employeDao.getImutationsPeriod(chantier, dateDebut, dateFin);
	}
	
	
}
